<?php require_once('Connections/staf.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_staf, $staf);
$query_login = "SELECT * FROM maklumat_staf";
$login = mysql_query($query_login, $staf) or die(mysql_error());
$row_login = mysql_fetch_assoc($login);
$totalRows_login = mysql_num_rows($login);
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['nama'])) {
  $loginUsername=$_POST['nama'];
  $password=$_POST['noic'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "index.php";
  $MM_redirectLoginFailed = "loginfailed.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_staf, $staf);
  
  $LoginRS__query=sprintf("SELECT id, nama, noic, access_user FROM maklumat_staf WHERE nama=%s AND noic=%s",
    GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 
   
  $LoginRS = mysql_query($LoginRS__query, $staf) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
	  $result = mysql_fetch_assoc($LoginRS);
     //$loginStrGroup = $result['access_user'];
	 $_SESSION['userid'] = $result['id'];
	 $_SESSION['access_user'] = $result['access_user'];
         $_SESSION['noic'] = $result['noic'];
    $loginStrGroup = '';
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;	      

    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if IE 9]>    <html class="no-js ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<title>Login</title>
    
	<link rel="icon" type="image/png" href="favicon.png">
    	<!-- This is the traditional favicon.
		 - size: 16x16 or 32x32
		 - transparency is OK
		 - see wikipedia for info on browser support: http://mky.be/favicon/-->
		 
	<link rel="apple-touch-icon" href="apple-touch-icon-precomposed.png">
	<!-- The is the icon for iOS's Web Clip.
		 - size: 57x57 for older iPhones, 72x72 for iPads, 114x114 for iPhone4's retina display (IMHO, just go ahead and use the biggest one)
		 - To prevent iOS from applying its styles to the icon name it thusly: apple-touch-icon-precomposed.png
		 - Transparency is not recommended (iOS will put a black BG behind the icon) -->
         
	<meta name="description" content="">
	<meta name="author" content="Falcon Creative Studio - Shahul Hameed">
	
    <!-- Fonts -->
    <link rel="stylesheet" type="text/css" href="css/fonts.css">
    <link rel="stylesheet" type="text/css" href="css/font-awesome.css">
    
    <!-- Bootstrap -->
	<link href="css/bootstrap.css" rel="stylesheet" type="text/css" media="all">
    
    
    <link rel="stylesheet" type="text/css" href="css/style.css">
    <link rel="stylesheet" type="text/css" href="colors-css/default.css" class="colorCssStyles">
<link rel="stylesheet" type="text/css" href="css/responsive.css">
    <!--[if IE 8]>
	  <link rel="stylesheet" type="text/css" href="css/ie8.css">
	<![endif]-->    
    
    
    <script src="js/libs/modernizr-2.5.3.min.js"></script>
</head>
<body>
<p id="back-top"><a href="#top"><span class="icon-chevron-up"></span></a></p>
<!--[if lte IE 7]><p class=chromeframe>Your browser is <em>ancient!</em> <a href="http://browsehappy.com/">Upgrade to a different browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to experience this site.</p><![endif]-->

<!-- Top Header -->
<!-- Page Header -->
<!-- Banner -->
<!-- Page Content --><br>
<br>
<br>
<br>
<br>

<div role="main" id="mainContent" class="center row-fluid servicesPage clearfix">
	
    <!-- Services List -->
    <section class="newSection noMarginBottom clearfix services">
      <h2 class="borderLine uppercase"><span class="bg">LOGIN USER</span></h2> 
        <div class="row-fluid">
            <div class="span3 alignCenter">
                <div class="singleService">
                    <div class="sepCenter">
                        <div class="outerCircle rotate1">
                            <p class="icon190"><span class="icon-beaker"></span></p>
                        </div>
                    </div>
                </div>    
            </div>
            
            <div class="span9 animateIconServices">
            	<h3 class="serviceTitle">&nbsp;</h3><form action="<?php echo $loginFormAction; ?>" method="POST" name="form1" id="form1">
            	  <table width="100%" align="center">
    <tr>
      <td width="18%" height="50"><h3>NAMA PENUH</h3></td>
      <td width="82%" height="50"><label>
        <input name="nama" type="text" id="nama" size="30" class="span4"/>
        </label></td>
    </tr>
    <tr>
      <td height="50"><h3>KATA LALUAN</h3></td>
      <td height="50"><label>
        <input name="noic" type="password" id="noic" size="30" class="span4"/>
      </label></td>
    </tr>
    <tr>
      <td height="50">&nbsp;</td>
      <td height="50"><label>
        <input type="submit" name="button" id="button" value="Submit" />
        <input type="reset" name="button2" id="button2" value="Reset" />
      </label></td>
    </tr>
  </table>
</form>
</p>
          </div>
        </div>     
      	<!-- Seperate -->
     	<div class="sep double">&nbsp;</div>
        
  </section>       
</div><!-- End of mainContent -->

<!-- Footer -->
<!-- <script src="../../../ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> -->
<script src="../jquery/jquery_1.9.0_min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.8.2.min.js"><\/script>')</script>
<script src="js/bootstrap.min.js"></script>
<script src="js/plugins.js"></script>
<script src="js/script.js"></script>
<script type="text/javascript" src="../../../twitter.com/javascripts/blogger.js">  
</script>
<script type="text/javascript" src="https://api.twitter.com/1/statuses/user_timeline.json?screen_name=falcon_studio&amp;callback=twitterCallback2&amp;count=2">  </script>
<!-- end scripts-->

<script>
	var _gaq=[['_setAccount','UA-24743401-1'],['_trackPageview']];
	(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
	g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
	s.parentNode.insertBefore(g,s)}(document,'script'));
</script>

</body>
</html><?php
mysql_free_result($login);
?>
